# -*- coding: utf-8 -*-
import json
from math import ceil
from .base_spider import BaseSpider


class YilongSpider(BaseSpider):
    name = 'yilong'

    def get_datas(self, response):
        content = json.loads(response.text)
        return content['comments']

    def get_creator(self, data):
        return data['userName']

    def get_create_date(self, data):
        return data['commentDateTime']

    def get_content(self, data):
        return data['content']

    def get_star(self, data):
        return data['userRank']

    def get_page_size(self, response):
        return int(ceil(json.loads(response.text)['commentCount'] / 20))
